package com.csr.csrcheck.service.impl;

import com.csr.csrcheck.mapper.Important_notificationMapper;
import com.csr.csrcheck.pojo.Important_notification;
import com.csr.csrcheck.service.Important_notificationService;
import com.csr.csrcheck.service.ex.CompanyException;
import com.csr.csrcheck.util.PageResult;
import com.csr.csrcheck.util.PageUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Important_notificationServiceImpl implements Important_notificationService {
    @Resource
    private Important_notificationMapper important_notificationMapper;

    public PageResult getimportant_page(int pageNum, int pageSize, String product_name, String product_t_name) {
        return PageUtils.getPageResult(pageNum, pageSize, getPageInfo(pageNum, pageSize, product_name, product_t_name));
    }

    private PageInfo<Important_notification> getPageInfo(int pageNum, int pageSize, String product_name, String product_t_name) {
        PageHelper.startPage(pageNum, pageSize);
        List<Important_notification> list = this.important_notificationMapper.getimportant_page(product_name, product_t_name);
        if (list == null)
            throw new CompanyException("");
        return new PageInfo(list);
    }
}
